package day05;

import java.util.Arrays;
import java.util.Scanner;

public class Work {
    public static void main(String[] args) {
        int[] a = new int[10];
        for(int c = 0;c<a.length;c++){
            a[c] = (int)(Math.random()*100+1);
            System.out.println("a["+c+"]="+a[c]);
        }
        Arrays.sort(a);
        System.out.println("排序后");
        for(int c = 0;c<a.length;c++){
            System.out.println("a["+c+"]="+a[c]);
        }
        System.out.println("倒着排");
        for(int c = a.length-1;c>=0;c--){
            System.out.println("a["+c+"]="+a[c]);
        }

        //标准练习5:对数组进行升序排列，并输出排序后的结果
/*        int[] num = new int[10];
        for(int i = 0;i<num.length;i++){
            num[i] =(int)(Math.random()*100+1);
            System.out.println("num["+i+"]="+num[i]);
        }
        Arrays.sort(num);//对num做升序排序
        System.out.println("排序后");
        for(int i = 0;i<num.length;i++){
            System.out.println(num[i]);
        }
        System.out.println("倒着排序");
        for (int i = num.length-1;i>=0;i--){
            System.out.println(num[i]);
        }

 */

        //标准练习4:1. MaxOfArray求数组元素最大值
/*        int[] num = new int[10];
        for(int i = 0;i<num.length;i++){
            num[i]=(int)(Math.random()*100+1);
            System.out.println("num["+i+"]="+num[i]);
        }
        int max = num[0];
        for(int i = 0;i<num.length;i++){
            if(num[i]>max){
                max = num[i];
            }
        }
        System.out.println("最大值是:"+max);

 */

 /*
        int[] a = new int[10];
        for(int i = 0;i<a.length;i++){
            a[i]=(int)(Math.random()*10+1);
            System.out.println("a["+i+"]="+a[i]);
        }
        int max = a[0];
        for(int i = 0;i<a.length;i++){
            if(max<a[i]){
                max=a[i];
            }
        }
        System.out.println("最大值为:"+max);

 */

/*       int[] num = new int[10];
       int max =num[0];
       for (int i = 0;i<num.length;i++) {
           num[i] = (int) (Math.random() * 100 + 1);
           System.out.println("num[" + i + "]=" + num[i]);
       }
       for (int a = 0;a<num.length;a++){
            if(max<num[a]){
                max = num[a];
            }
        }
        System.out.println(max);

 */

/*        //标准练习3:数组小代码练习：声明、初始化、访问、遍历
        int[] num = new int[10];
        for (int i = 0;i<num.length;i++){
            num[i] = (int)(Math.random()*100+1);
            System.out.println("num["+i+"]="+num[i]);
        }
        System.out.println(num[1]);

 */

/*        int[] a = new int[10];//声明并初始化数组a(0,0,0,0,0,)
        System.out.println(a[0]);//访问数组a第一个元素值
        for(int i = 0;i<a.length;i++){//遍历
            a[i] = (int)(Math.random()*100+1);
            System.out.println(a[i]);
        }

 */

/*        //标准2:MultiTable九九乘法表,要求：输出九九乘法表
        for(int a = 1;a<=9;a++){
            for(int a1 = 1;a1<=a;a1++){
                System.out.print(a1+"*"+a+"="+a*a1+"\t");
            }
            System.out.println();
        }

 */

 /*       for(int num = 1;num<=9;num++){
            for(int i = 1;i<=num;i++){
                System.out.print(i+"*"+num+"="+i*num+"\t");
            }
            System.out.println();
        }

  */

/*       //标准1: Addition随机加法运算器
       // 要求：由系统随机出10道加法题，而后由用户来答题，答题后输出"答对了"或"答错了"，答对1题得10分，答错1题不扣分，最后输出总分数。
        Scanner scan = new Scanner(System.in);
        int score = 0;
        for (int i = 1;i<=10;i++){
            int a =(int)(Math.random()*10+1);
            int a1 =(int)(Math.random()*10+1);
            int c = a+a1;
            System.out.println("("+i+")"+a+"+"+a1+"=?");
            System.out.println("算吧");
            int c1 = scan.nextInt();
            if (c1==c){
                System.out.println("对了");
                score+=10;
            }else{
                System.out.println("错了");
            }
        }
        System.out.println("您的成绩是:"+score);

 */

/*        Scanner scan = new Scanner(System.in);
        int a = 0;//成绩
        for(int b = 1;b<=10;b++){
            int c = (int)(Math.random()*100+1);
            int c1 = (int)(Math.random()*100+1);
            int result = c+c1;//答案
            System.out.println("开始");
            System.out.println("("+b+")"+c+"+"+c1+"=？");
            int  result1 = scan.nextInt();
            if(result1==result){
                System.out.println("答对了");
                a +=10;
            }else{
                System.out.println("答错了");
            }
        }
        System.out.println("你的分数是:"+a);

 */
    }
}
